USE [BD_Taller]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Vehiculo]') AND parent_object_id = OBJECT_ID(N'[dbo].[Orden_Trabajo]'))
ALTER TABLE [dbo].[Orden_Trabajo] DROP CONSTRAINT [FK_Vehiculo]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Cliente]') AND parent_object_id = OBJECT_ID(N'[dbo].[Vehiculo]'))
ALTER TABLE [dbo].[Vehiculo] DROP CONSTRAINT [FK_Cliente]
GO

USE [BD_Taller]
GO

/****** Object:  Table [dbo].[Vehiculo]    Script Date: 07/19/2013 11:56:09 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Vehiculo]') AND type in (N'U'))
DROP TABLE [dbo].[Vehiculo]
GO

USE [BD_Taller]
GO

/****** Object:  Table [dbo].[Vehiculo]    Script Date: 07/19/2013 11:56:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Vehiculo](
	[id_Vehiculo] int IDENTITY(1,1) NOT NULL,
	[patente] [varchar](10) NOT NULL,
	[year] [int] NULL,
	[marca] varchar(255) null,
	[modelo] varchar(255) null,
	[chasis] varchar(50) null --,
	--[rut_Cliente] [bigint] NULL,
 CONSTRAINT [PK_Vehiculo] PRIMARY KEY CLUSTERED 
(
	[id_Vehiculo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

--ALTER TABLE [dbo].[Vehiculo]  WITH CHECK ADD  CONSTRAINT [FK_Cliente] FOREIGN KEY([rut_Cliente])
--REFERENCES [dbo].[Cliente] ([rut_Cliente])
--GO

--ALTER TABLE [dbo].[Vehiculo] CHECK CONSTRAINT [FK_Cliente]
--GO


ALTER TABLE [dbo].[Orden_Trabajo]  WITH CHECK ADD  CONSTRAINT [FK_Vehiculo] FOREIGN KEY([id_Vehiculo])
REFERENCES [dbo].[Vehiculo] ([id_Vehiculo])
GO

ALTER TABLE [dbo].[Orden_Trabajo] CHECK CONSTRAINT [FK_Vehiculo]
GO
